package com.mdnote.practice.plus_search.prune;

/**
 * @author Rhythm-2019
 * @version 1.0
 * @date 2020/9/26
 * @description 爬楼梯问题
 */
public class LeetCode70 {

    public int climbStairs(int n) {
        int memo[] = new int[n + 1];
        return _climb(n, memo);
    }

    public int _climb(int n, int[] memo) {
        if (n <= 2) {
            return n;
        }

        if (memo[n] == 0) {
            memo[n] = _climb(n - 1, memo) + _climb(n - 2, memo);
        }
        return memo[n];

    }
}
